#include <fstream>
#include <string>
#include <math.h>
#include <iostream>
#include "Light.h"

using namespace std;
  

Light::Light(GLenum NumLight): NumLight(NumLight) {

  Light_Ambient[0] = 0.3;
  Light_Ambient[1] = 0.3;
  Light_Ambient[2] = 0.3;
  Light_Ambient[3] = 1.0;

  Light_Diffuse[0] = 0.6;
  Light_Diffuse[1] = 0.6;
  Light_Diffuse[2] = 0.6;
  Light_Diffuse[3] = 1.0;

  Light_Specular[0] = 0.3;
  Light_Specular[1] = 0.3;
  Light_Specular[2] = 0.3;
  Light_Specular[3] = 1.0;

  Light_Position[0] = 512.0;
  Light_Position[1] = 512.0;
  Light_Position[2] = 350.0;
  Light_Position[3] = 1.0;
}
 
void Light::set_Light_Ambient(GLfloat a, GLfloat b, GLfloat c, GLfloat d){
  Light_Ambient[0] = a;
  Light_Ambient[1] = b;
  Light_Ambient[2] = c;
  Light_Ambient[3] = d;
}
void Light::set_Light_Diffuse(GLfloat a, GLfloat b, GLfloat c, GLfloat d){
  Light_Diffuse[0] = a;
  Light_Diffuse[1] = b;
  Light_Diffuse[2] = c;
  Light_Diffuse[3] = d;
}
void Light::set_Light_Specular(GLfloat a, GLfloat b, GLfloat c, GLfloat d){
  Light_Specular[0] = a;
  Light_Specular[1] = b;
  Light_Specular[2] = c;
  Light_Specular[3] = d;
}  
void Light::set_Light_Position(GLfloat a, GLfloat b, GLfloat c, GLfloat d){
  Light_Position[0] = a;
  Light_Position[1] = b;
  Light_Position[2] = c;
  Light_Position[3] = d;
} 
   
void Light::get_All_Light(){
  int i=0;
  cout<<"Light_Ambient :"<<endl;
  for(i=0;i<4;i++)cout<<Light_Ambient[i]<<endl;
  cout<<"Light_Diffuse :"<<endl;
  for(i=0;i<4;i++)cout<<Light_Diffuse[i]<<endl;
  cout<<"Light_Specular :"<<endl;
  for(i=0;i<4;i++)cout<<Light_Specular[i]<<endl;
  cout<<"Light_Position :"<<endl;
  for(i=0;i<4;i++)cout<<Light_Position[i]<<endl;
}

  
void Light::ActiveLight (){
  glEnable(GL_LIGHTING);    
  glEnable(NumLight);

  glLightfv( NumLight, GL_AMBIENT, Light_Ambient );
  glLightfv( NumLight, GL_DIFFUSE, Light_Diffuse );
  glLightfv( NumLight, GL_SPECULAR, Light_Specular );
  glLightfv( NumLight, GL_POSITION, Light_Position );
}

void Light::DisactiveLight(){  
  glDisable(GL_LIGHTING); 
  glDisable(NumLight);
}
